# Copyright 2024 CHINA MERCHANTS BANK CO., LTD.
# Copyright 2024 Huawei Technologies Co., Ltd
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================

import os
import argparse
from easydict import EasyDict

import mindspore as ms


def merge_stategy(src_strategy_dirs, dst_strategy_file):
    ms.parallel.merge_pipeline_strategys(src_strategy_dirs, dst_strategy_file)


if __name__=="__main__":
    work_path = os.path.dirname(os.path.abspath(__file__))
    parser = argparse.ArgumentParser()
    parser.add_argument(
        '--src_strategy_dirs',
        default=None,
        type=str,
        required=True,
        help='src strategy dirs')
    parser.add_argument(
        '--dst_strategy_file',
        default=None,
        type=str,
        required=True,
        help='merged strategy file')

    args_, rest_args_ = parser.parse_known_args()
    args_ = EasyDict(vars(args_))
    merge_stategy(args_.src_strategy_dirs, args_.dst_strategy_file)